package com.lh.process.engine.process;

import com.lh.process.engine.context.ProcessContext;

/**
 * @author: linghao
 * @since: 2022/10/23
 */
public abstract class AbstractProcessor implements Processor{

    private String name;

    @Override
    public void process(ProcessContext context) {
        beforeProcess(context);
        processInternal(context);
        afterProcess(context);
    }

    protected  void afterProcess(ProcessContext context){
        //公共前置
    }

    protected abstract void processInternal(ProcessContext context);

    protected  void beforeProcess(ProcessContext context){
        //公共后置
    }

    @Override
    public void caughtException(ProcessContext context, Throwable throwable) {

    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return name;
    }
}
